﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Train_ChargeDepart : System.Web.UI.Page
{
    private Srvtools.WebDataSet WMaster;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitializeComponent();

            Master.DataSource = WMaster;


            MasterPage_MasterPage mpg = (MasterPage_MasterPage)this.Page.Master;
            mpg.HelpHref = "~/Help/Train/按部门统计费用.htm";
            mpg.PageName = "按部门统计费用";
            mpg.PicUrl = "";
            mpg.IntiBar();
        }
    }

    private void InitializeComponent()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Train_ChargeDepart));
        this.WMaster = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).BeginInit();
        // 
        // WMaster
        // 
        this.WMaster.Active = true;
        this.WMaster.AlwaysClose = false;
        this.WMaster.DeleteIncomplete = true;
        this.WMaster.Guid = null;
        this.WMaster.LastKeyValues = null;
        this.WMaster.Locale = new System.Globalization.CultureInfo("zh-CN");
        this.WMaster.PacketRecords = 100;
        this.WMaster.Position = -1;
        string where = "1=1";
        if (ViewState["depId"] != null)
            where += " AND department.departmentid like '" + ViewState["depId"].ToString() + "%'";
        if (ViewState["year"] != null)
            where += " AND year(Train_Issue.TrainDate)='" + ViewState["year"].ToString() + "' ";
        if (ViewState["month"] != null)
            where += " AND month(Train_Issue.TrainDate)='" + ViewState["month"].ToString() + "' ";
        this.WMaster.SetWhere(where);
        this.WMaster.RemoteName = "Train.View_ChargeDepart";
        this.WMaster.ServerModify = false;
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).EndInit();

    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string depId = this.DepartmentDList1.SelectDepmanetId;
        string year = this.DSelYearMonth1.SelectYear;
        string month = this.DSelYearMonth1.SelectMonth;

        if (depId != "0")
            this.ViewState["depId"] = depId;
        if (year != "0")
            this.ViewState["year"] = year;
        if (month != "0")
            this.ViewState["month"] = month;

        InitializeComponent();
        Master.DataSource = WMaster;
        this.ViewState.Clear();
    }
}
